package com.gitee.paymenthystrix.service;

import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName PaymentService
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/12/21 9:53
 **/
@Service
public class PaymentService {

    public String paymentOk(Integer id){
        return "线程池:" + Thread.currentThread().getName() + "paymentok,id:" +id + "正常访问";
    }


    public String paymentTimeout(Integer id ) {
        int timeNumber = 3;

        try {
            TimeUnit.SECONDS.sleep(timeNumber);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return String.format("线程池 %s paymentTimeOut, id %s 耗时(秒)",Thread.currentThread().getName(),timeNumber);
    }
}
